package com.hao.rabbitmqproduce.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class MyRabbitMQConfig {
    //queue
    public static final String EXCHANGE_NAME= "boot_queue_exchange";
    public static final String QUEUE_NAME= "boot_queue";
    @Bean("bootExchange")
    public Exchange bootExchange(){
        return ExchangeBuilder.directExchange(EXCHANGE_NAME).build();
    }
    @Bean("bootQueue")
    public Queue bootQueue(){
        return QueueBuilder.durable(QUEUE_NAME).build();
    }
    @Bean
    public Binding queueBinding(@Qualifier("bootQueue") Queue queue,@Qualifier("bootExchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("queue").noargs();
    }

}
